
package hibernate.entities;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;

@Entity
@Table(name = "piece")
public class Piece {

	@Id
	@Column(name="id")
	@GeneratedValue(strategy=GenerationType.AUTO)
	private int id;
	
	private String nom;
	
	@OneToMany(mappedBy="piece", fetch=FetchType.LAZY)
	private Set<User> users;
	
	@OneToOne
	@JoinColumn(name="fk_nord")
	private Piece nord;
	
	@OneToOne
	@JoinColumn(name="fk_sud")
	private Piece sud;
	
	@OneToOne
	@JoinColumn(name="fk_est")
	private Piece est;

	@OneToOne
	@JoinColumn(name="fk_ouest")
	private Piece ouest;
	
	public Piece(){}

	public Piece(String nom, Piece nord, Piece sud, Piece est, Piece ouest) {
		super();
		this.nom = nom;
		this.nord = nord;
		this.sud = sud;
		this.est = est;
		this.ouest = ouest;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public Piece getNord() {
		return nord;
	}

	public void setNord(Piece nord) {
		this.nord = nord;
	}

	public Piece getSud() {
		return sud;
	}

	public void setSud(Piece sud) {
		this.sud = sud;
	}

	public Piece getEst() {
		return est;
	}

	public void setEst(Piece est) {
		this.est = est;
	}

	public Piece getOuest() {
		return ouest;
	}

	public void setOuest(Piece ouest) {
		this.ouest = ouest;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}
	
	
	
}
